#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT(configure.in)
AC_CONFIG_SRCDIR(src/iptux.cpp)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(iptux, 0.4.5)

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_MKDIR_P

# Checks for libraries.
# FIXME: Replace `main' with a function in `-lcairo':
#AC_CHECK_LIB([cairo], [main])
# FIXME: Replace `main' with a function in `-ldl':
#AC_CHECK_LIB([dl], [main])
# FIXME: Replace `main' with a function in `-lrt':
#AC_CHECK_LIB([rt], [main])

# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/socket.h sys/time.h sys/vfs.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_INLINE
AC_C_CONST
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_HEADER_TIME
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T

# Checks for library functions.
AC_FUNC_CLOSEDIR_VOID
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MALLOC
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([bzero getcwd gettimeofday inet_ntoa memmove mkdir rmdir socket strcasecmp strchr strerror strncasecmp strpbrk strrchr strstr])

AC_DEFINE(__IP_TUX__)
AC_ARG_ENABLE(message,
		[  --disable-message       disable print message], ,
		enable_message=yes)
if test "${enable_message}" = yes ; then
AC_DEFINE(MESSAGE)
fi
AC_ARG_ENABLE(warning,
		[  --disable-warning       disable print warning], ,
		enable_warning=yes)
if test "${enable_warning}" = yes ; then
AC_DEFINE(WARNING)
fi
AC_ARG_ENABLE(trace,
		[  --enable-trace          enable print trace], ,
		enable_trace=no)
if test "${enable_trace}" = yes ; then
AC_DEFINE(TRACE)
fi

dnl In Autoconf 2.61, ${bindir} -> ${exec_prefix}
dnl In Autoconf 2.61, ${datadir} --> ${datarootdir} --> ${prefix}
test "${prefix}" = NONE && prefix="${ac_default_prefix}"
test "${exec_prefix}" = NONE && exec_prefix="${prefix}"
defdir=`eval echo ${bindir}`
AC_DEFINE_UNQUOTED(__EXEC_PATH, "${defdir}")
defdir=`eval echo ${datadir}`
defdir=`eval echo ${defdir}`
AC_DEFINE_UNQUOTED(__DATA_PATH, "${defdir}")
localedir="${defdir}/locale"
AC_DEFINE_UNQUOTED(__LOCALE_PATH, "${localedir}")
desktopdir="${defdir}/applications"
AC_DEFINE_UNQUOTED(__DESKTOP_PATH, "${desktopdir}")
AC_SUBST(desktopdir)
logodir="${defdir}/pixmaps"
AC_DEFINE_UNQUOTED(__LOGO_PATH, "${logodir}")
AC_SUBST(logodir)
icondir="${defdir}/iptux/pixmaps/icon"
AC_DEFINE_UNQUOTED(__ICON_PATH, "${icondir}")
AC_SUBST(icondir)
tipdir="${defdir}/iptux/pixmaps/tip"
AC_DEFINE_UNQUOTED(__TIP_PATH, "${tipdir}")
AC_SUBST(tipdir)
menudir="${defdir}/iptux/pixmaps/menu"
AC_DEFINE_UNQUOTED(__MENU_PATH, "${menudir}")
AC_SUBST(menudir)
sounddir="${defdir}/iptux/sound"
AC_DEFINE_UNQUOTED(__SOUND_PATH, "${sounddir}")
AC_SUBST(sounddir)

gtk_modules="gtk+-2.0 >= 2.0.0"
PKG_CHECK_MODULES(GTK, [$gtk_modules])
glib_modules="glib-2.0 >= 2.16.0"
PKG_CHECK_MODULES(GLIB, [$glib_modules])
gthread_modules="gthread-2.0 >= 2.0.0"
PKG_CHECK_MODULES(GTHREAD, [$gthread_modules])
gconf_modules="gconf-2.0 >= 2.0.0"
PKG_CHECK_MODULES(GCONF, [$gconf_modules])
gst_modules="gstreamer-0.10 >= 0.10.0"
PKG_CHECK_MODULES(GST, [$gst_modules], have_gst=yes, have_gst=no)
if test "${have_gst}" = yes ; then
AC_DEFINE(HAVE_GST)
else
AC_MSG_WARN(You need GStreamer-0.10 or later installed if you need sound relevant functions)
fi
PACKAGE_CFLAGS="${GTK_CFLAGS} ${GTHREAD_CFLAGS} ${GCONF_CFLAGS} ${GST_CFLAGS}"
PACKAGE_LIBS="${GTK_LIBS} ${GLIB_LIBS} ${GTHREAD_LIBS} ${GCONF_LIBS} ${GST_LIBS}"
AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)

GETTEXT_PACKAGE=iptux
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "${GETTEXT_PACKAGE}")

dnl Add the languages which your application supports here.
ALL_LINGUAS="en_GB zh_CN"
AM_GLIB_GNU_GETTEXT

AC_OUTPUT(Makefile desktop/Makefile pixmaps/Makefile po/Makefile.in sound/Makefile \
	src/Makefile src/uninstall/Makefile)
